package com.carbon.system.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.carbon.common.api.Paging;
import com.carbon.common.service.BaseServiceImpl;
import com.carbon.system.entity.CarbonArticleComment;
import com.carbon.system.mapper.CarbonArticleCommentMapper;
import com.carbon.system.param.CarbonArticleCommentQueryParam;
import com.carbon.system.service.CarbonArticleCommentService;
import com.carbon.system.vo.CarbonArticleCommentQueryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * CarbonArticleComment服务实现类
 * 负责处理文章评论相关的业务操作
 * 继承自BaseServiceImpl，使用MyBatis Plus进行数据操作
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class CarbonArticleCommentServiceImpl extends BaseServiceImpl<CarbonArticleCommentMapper, CarbonArticleComment> implements CarbonArticleCommentService {

    @Resource
    private CarbonArticleCommentMapper carbonArticleCommentMapper;

    /**
     * 根据ID获取文章评论信息
     *
     * @param id 文章评论的ID
     * @return 文章评论信息
     */
    @Override
    public CarbonArticleCommentQueryVo getCarbonArticleCommentById(Serializable id) {
        return carbonArticleCommentMapper.getCarbonArticleCommentById(id);
    }

    /**
     * 获取文章评论分页列表
     *
     * @param param 查询参数对象，包含分页和过滤条件
     * @return 分页后的文章评论列表
     */
    @Override
    public Paging<CarbonArticleCommentQueryVo> getCarbonArticleCommentPageList(CarbonArticleCommentQueryParam param) {
        IPage<CarbonArticleCommentQueryVo> iPage = carbonArticleCommentMapper.getCarbonArticleCommentPageList(getPage(param), param);
        return new Paging<>(iPage);
    }

}
